<template>
  <view class="container">
    <!-- 使用循环优化结构 -->
	<view class="card-header" @click="toTask">
		<text class="title">任务待办列表</text>
		<uni-icons type="arrow-right" size="20"></uni-icons>
		</view>
    <view 
      class="card" 
      v-for="(item, index) in cardList" 
      :key="index"
    >
      <view class="card-header" @click="toggleCollapse(index)">
        <text class="title">{{ item.title }}</text>
        <uni-icons 
          :type="isOpen[index] ? 'arrow-down' : 'arrow-right'" 
          size="20"
        />
      </view>
      <view class="card-content" v-show="isOpen[index]">
        <view 
          class="content-item"
          v-for="(subItem, subIndex) in item.content"
          :key="subIndex" @click="handerMenu(index,subIndex)"
        >
          {{ subItem }}
        </view>
      </view>
    </view>
    
    <!-- 底部统计信息 -->
	 <view class="stats-title">邻里成就</view>
    <view class="stats-container">
      <view class="stats-item" @click="test">服务评价汇总</view>
      <view class="stats-item">意见反馈汇总</view>
      <view class="stats-item">成员流动分析</view>
      <view class="stats-item">商圈访问分析</view>
      </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
		groupId:"",
      isOpen: new Array(6).fill(false), // 初始化6个面板状态
      cardList: [
              
        {
          title: '邻里信息管理',
          content: ['修改邻里信息', '邻里公告管理', '邻里广告管理','通知设置']
        },
        {
          title: '邻里成员管理',
          content: ['成员列表']
        },
        {
          title: '邻里商店管理',
          content: ['新品上架','商品管理',"代销审核"]
        },
        {
          title: '订单管理',
          content: ['订单处理', '交易统计']
        },
        {
          title: '商圈管理',
          content: ['商圈信息审核', '商圈信息维护', '商圈访问统计']
        }
      ]
    };
  },
  onLoad(res) {
  this.groupId=	res.groupId
  },
  methods: {
	  test(){
		uni.navigateTo({
			url:'/pages/text/text'
		})  
	  },
	  toTask(){
		  uni.navigateTo({
		  	url: `/own/ownTask/ownTask?groupId=${this.groupId}`,
		  	success: res => {},
		  	fail: () => {},
		  	complete: () => {}
		  });
	  },
    toggleCollapse(index) {
      // 使用$set确保响应式更新
      this.$set(this.isOpen, index, !this.isOpen[index])
    },
	handerMenu(index,subIndex){
		console.log(index,subIndex);
	if(index===3&&subIndex===0){
		uni.navigateTo({
			url:'/own/saleGood/saleGood'
		})
	}
	if(index===0&&subIndex===0){
		console.log('55555')
		uni.navigateTo({
			url:'/own/editGroupInfo/editGroupInfo',
			success() {
				
			},
			fail(e) {
				console.log(e);
			}
		})
		
	}
	if(index===1&&subIndex===0){

		uni.navigateTo({
			url:'/own/addMember/addMember',
			success(res) {
				console.log(res);
			},
			fail(e) {
				console.log(e)
			}
		})
		
	}	

	
		if(index===4&&subIndex===2){
			uni.navigateTo({
				url:'/pages/regOwn/regOwn'
			})
			
		}
		if(index===2&&subIndex===1){
			uni.navigateTo({
				url:'/pages/shopping/shopping'
			})
		}
	}
  }
};
</script>

<style scoped>
.container {
  padding: 20rpx;
  padding-bottom: 40rpx;
}

.card {
  margin-bottom: 20rpx;
  background: #fff;
  border-radius: 10rpx;
  box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.1);
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20rpx;
  border-bottom: 1rpx solid #eee;
}

.title {
  font-size: 32rpx;
  font-weight: 500;
  color: #333;
}

.card-content {
  padding: 20rpx 30rpx;
}

.content-item {
  padding: 20rpx 0;
  font-size: 28rpx;
  color: #666;
  border-bottom: 1rpx solid #f5f5f5;
}

.content-item:last-child {
  border-bottom: none;
}

/* 新增统计样式 */
.stats-container {
  margin-top: 40rpx;
  background: #fff;
  border-radius: 10rpx;
  padding: 20rpx;
  box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.1);
}
.stats-title{
	text-align: center;
	font-size: 32rpx;
    font-weight: 500;
}

.stats-item {
  padding: 25rpx 0;
  font-size: 28rpx;
  color: #444;
  border-bottom: 1rpx solid #eee;
}

.stats-item:last-child {
  border-bottom: none;
}
</style>